package Observer;

import java.util.Observable;
import java.util.Observer;

/**
 * @creater chenzhe
 * @date 2018/10/26 16:05
 */
public class CurrentConditionsDisplay  implements Observer,DisplayElement{
    private  float  temperature;
    private float humitidy;
    Observable observable;


    public CurrentConditionsDisplay(Observable observable) {
        this.observable=observable;
        observable.addObserver(this);
    }

    @Override
    public void display() {
        System.out.println("Current conditions: " + temperature
                + "F degrees and " + humitidy + "% humidity");
    }



    @Override
    public void update(Observable o, Object arg) {
        if (o instanceof WeatherData) {
           WeatherData weatherData= (WeatherData) o;
            this.temperature = weatherData.getTemperature();
            this.humitidy=weatherData.getHumidity();
            display();
        }
    }
}
